package com.zjitc.dao;

import com.zjitc.pojo.Customer;
import com.zjitc.pojo.DataSourceFactory;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/15 16:27
 * @description:
 */
public class CustomerDao {
  //连接数据库
  private QueryRunner runner;

  public CustomerDao() {
    runner = new QueryRunner(DataSourceFactory.getDataSource());
  }

  public List<Customer> display() throws SQLException {
    String sql = "select * from customer";
    return runner.query(sql, new BeanListHandler<Customer>(Customer.class));
  }
}
